﻿<script>
    function delete_item(type, id, obj)
    {
        if(confirm('$appHelper.GetLocalizationString($response.Domain, "Delete") ' + obj + '?'))
        {
            AjaxHelper.Process(type + "/Delete/" + id, function(response)
            {
                alert(response.Message);
                if(response.MessageType == "Success")
                    document.location.href = '$urlHelper.GetViewUrl($uri.Parse("$response.Domain.URI.Model/Search/All"))';
            });
        }
    }
</script>
<h1>
    <a href='$urlHelper.GetViewUrl($uri.Parse("$appHelper.GetTypeName($response.Domain.Type)/Search/All"))'>
        $appHelper.GetLocalizationString($response.Domain, $response.Domain.Type.Name)
    </a>
</h1>
<h2>$response.Domain.Instance</h2>
<h3>$response.Domain.Label</h3>
  <div class="content-container">
    <table>
      <tbody>
        #foreach($field in $response.Domain.Domains)
            #if($field.CanRead)
                <tr>
                  <td class="label">
                    <label for="$field.UniqueID">$field.Label</label>
                  </td>
                  <td class="field">
                    $renderer.ProcessDomain($response, $field)
                  </td>
                </tr>
            #end
        #end
      </tbody>
      <tfoot>
        <tr>
          <td colspan="2">
            <hr />
            <input type="button" class="button" value="$appHelper.GetLocalizationString($response.Domain, "Edit")"
                onclick='document.location.href = "$urlHelper.GetViewUrl($uri.Parse("$response.Domain.URI.Model/Edit/$response.Domain.Value"))"; ' />
            
            <input type="button" class="button" value="$appHelper.GetLocalizationString($response.Domain, "Delete")"
                onclick='delete_item("$response.Domain.URI.Model","$response.Domain.Value", "$response.Domain.Instance");' />
                
            #foreach($method in $appHelper.GetModelSchema($response.Domain).InstanceMethods)
              <input type="button" class="button" value="$method.Label"
                  onclick='document.location.href = "$urlHelper.GetViewUrl($method.URI)"; ' />
            #end
            
            <input type="button" class="button" value="$appHelper.GetLocalizationString($response.Domain, "Back")" onclick='history.go(-1);' />
          </td>
        </tr>
      </tfoot>
    </table>
  </div>